package com.study.system.gatewayservice.config;

import jakarta.annotation.Resource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;
import java.util.Set;

/**
 * 读取白名单配置
 */
//@ConfigurationProperties(prefix = "user-gateway-login")
@Configuration
public class WhiteListConfig {

    public static final String KEY = "white-list";

    @Resource
    private RedisTemplate<String,String> redisTemplate;

    /**
     * 读取白名单
     * @return
     */
    public Set<String> getWhiteList() {
        //从redis中读取白名单
        return redisTemplate.opsForSet().members(KEY);
    }

    /**
     * 添加白名单
     * @param urls
     */
    public void setWhiteList(String... urls){
        redisTemplate.opsForSet().add(KEY,urls);
    }

//    //白名单
//    private Set<String> whiteList;

//    public void setWhiteList(List<String> whiteList) {
//        this.whiteList = whiteList;
//    }
}
